/*
 * Copyright (C) 2012 Realtek Semiconductor Corp.
 * All Rights Reserved.
 *
 * This program is the proprietary software of Realtek Semiconductor
 * Corporation and/or its licensors, and only be used, duplicated,
 * modified or distributed under the authorized license from Realtek.
 *
 * ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
 * THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
 *
 */


#include "app_basic.h"

MIB_TABLE_INFO_T gMibOnuCapabilityTableInfo;
MIB_ATTR_INFO_T  gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ATTR_NUM];
MIB_TABLE_ONUCAPABILITY_T gMibOnuCapabilityDefRow;
MIB_TABLE_OPER_T gMibOnuCapabilityOper;


GOS_ERROR_CODE mibTable_init(MIB_TABLE_INDEX tableId)
{
    gMibOnuCapabilityTableInfo.Name = "OnuCapability";
    gMibOnuCapabilityTableInfo.ShortName = "ONUCAP";
    gMibOnuCapabilityTableInfo.Desc = "ONU capability";
    gMibOnuCapabilityTableInfo.ClassId = OMCI_ME_CLASS_CTC_ONU_CAPABILITY;
    gMibOnuCapabilityTableInfo.InitType = (UINT32)(OMCI_ME_INIT_TYPE_ONU);
    gMibOnuCapabilityTableInfo.StdType = (UINT32)(OMCI_ME_TYPE_PROPRIETARY);
    gMibOnuCapabilityTableInfo.ActionType = (UINT32)(OMCI_ME_ACTION_GET);
    gMibOnuCapabilityTableInfo.pAttributes = &(gMibOnuCapabilityAttrInfo[0]);

	gMibOnuCapabilityTableInfo.attrNum = MIB_TABLE_ONUCAPABILITY_ATTR_NUM;
	gMibOnuCapabilityTableInfo.entrySize = sizeof(MIB_TABLE_ONUCAPABILITY_T);
	gMibOnuCapabilityTableInfo.pDefaultRow = &gMibOnuCapabilityDefRow;

    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].Name = "EntityId";
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_OPERATIONID_INDEX - MIB_TABLE_FIRST_INDEX].Name = "OperationId";
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CTCSPEC_VERSION_INDEX - MIB_TABLE_FIRST_INDEX].Name = "CtcSpecVer";
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].Name = "OnuType";
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_TXPWR_SUPPLY_CTRL_INDEX - MIB_TABLE_FIRST_INDEX].Name = "TxPwrSupplyCtrl";
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CUSTOMIZED_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].Name = "CustomizedOnuType";

    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Entity ID";
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_OPERATIONID_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Operator ID";
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CTCSPEC_VERSION_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "CTC Spec Version";
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "ONU Type";
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_TXPWR_SUPPLY_CTRL_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Tx Power Supply Control";
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CUSTOMIZED_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Customized ONU Type";

    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_OPERATIONID_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_STR;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CTCSPEC_VERSION_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT8;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT8;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_TXPWR_SUPPLY_CTRL_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT8;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CUSTOMIZED_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT8;

    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_OPERATIONID_INDEX - MIB_TABLE_FIRST_INDEX].Len = 4;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CTCSPEC_VERSION_INDEX - MIB_TABLE_FIRST_INDEX].Len = 1;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].Len = 1;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_TXPWR_SUPPLY_CTRL_INDEX - MIB_TABLE_FIRST_INDEX].Len = 1;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CUSTOMIZED_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].Len = 1;

    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = TRUE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_OPERATIONID_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CTCSPEC_VERSION_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_TXPWR_SUPPLY_CTRL_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CUSTOMIZED_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;

    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_OPERATIONID_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CTCSPEC_VERSION_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_TXPWR_SUPPLY_CTRL_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CUSTOMIZED_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;

    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_OPERATIONID_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_CHAR;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CTCSPEC_VERSION_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_TXPWR_SUPPLY_CTRL_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CUSTOMIZED_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;

    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_OPERATIONID_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CTCSPEC_VERSION_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_TXPWR_SUPPLY_CTRL_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CUSTOMIZED_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;

    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_OPERATIONID_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CTCSPEC_VERSION_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_TXPWR_SUPPLY_CTRL_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CUSTOMIZED_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;

    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_OPERATIONID_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CTCSPEC_VERSION_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_TXPWR_SUPPLY_CTRL_INDEX- MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibOnuCapabilityAttrInfo[MIB_TABLE_ONUCAPABILITY_CUSTOMIZED_ONU_TYPE_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_PRIVATE;

    memset(&gMibOnuCapabilityDefRow, 0x00, sizeof(gMibOnuCapabilityDefRow));
    snprintf(gMibOnuCapabilityDefRow.OperationId, MIB_TABLE_ONUCAPABILITY_OPERATIONID_LEN, "CTC");
    gMibOnuCapabilityDefRow.CtcSpecVer = ONUCAPABILITY_CTC_SPEC_VERSION;
    gMibOnuCapabilityDefRow.CustomizedOnuType = ONUCAPABILITY_HGU_ONU_TYPE;
    gMibOnuCapabilityDefRow.TxPwrSupplyCtrl = ONUCAPABILITY_SUPPORT_TXRX_PWR_CTRL;

    memset(&gMibOnuCapabilityOper, 0x0, sizeof(MIB_TABLE_OPER_T));
    gMibOnuCapabilityOper.meOperDrvCfg = NULL;
    gMibOnuCapabilityOper.meOperConnCheck = NULL;
    gMibOnuCapabilityOper.meOperDump = omci_mib_oper_dump_default_handler;
	gMibOnuCapabilityOper.meOperConnCfg = NULL;

	MIB_TABLE_ONUCAPABILITY_INDEX = tableId;
    MIB_InfoRegister(tableId, &gMibOnuCapabilityTableInfo, &gMibOnuCapabilityOper);

    return GOS_OK;
}

